<%--
  Created by IntelliJ IDEA.
  User: 20064
  Date: 2020/2/12
  Time: 13:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理员登录</title>
    <meta name="viewport" content="width=device-width">
    <link href="../css/base.css" rel="stylesheet" type="text/css">
    <link href="../css/adminLogin.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="login">
    <form action="adminLogin.do" method="post" id="form">
        <div class="logo"></div>
        <div class="login_form">
            <div class="user">
                <input class="text_value" name="adminAccount" type="text" placeholder="账号" required="required">
                <input class="text_value" name="adminPwd" type="password" placeholder="密码" required="required">
            </div>
            <button class="button" id="submit" type="submit">登录</button>
        </div>

        <div id="tip"></div>
        <div class="foot">
            &copy;2020/2/12
        </div>
    </form>
</div>
</body>
<script type="text/javascript" src="../js/jquery-3.4.1/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../js/bootstrap-4.4.1-dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
    $("form").submit(function () {
        if (checkAdminAccount() === false || checkAdminPwd() === false) {
            $("input[name='adminAccount']").val("");
            $("input[name='adminPwd']").val("");
            return false;
        }
    });

    function checkAdminAccount() {
        var check = false;
        $.ajax({
            async: false,
            url: "checkAdminAccount.do",
            type: "post",
            data: {adminAccount: $("input[name='adminAccount']").val()},
            dateType: "json",
            success: function (result) {
                check = result.check;
                if (check === false) {
                    alert(result.msg);
                }
            }
        });
        return check;
    }

    function checkAdminPwd() {
        var check = false;
        $.ajax({
            async: false,
            url: "checkAdminPwd.do",
            type: "post",
            data: {adminAccount: $("input[name='adminAccount']").val(), adminPwd: $("input[name='adminPwd']").val()},
            dateType: "json",
            success: function (result) {
                check = result.check;
                if (check === false) {
                    alert(result.msg);
                }
            }
        });
        return check;
    }
</script>
</html>
